<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
	</head>

	<body>
		<div class="mui-content">
			<ul class="mui-table-view">
				<li class="mui-table-view-cell mui-media">
					<a id="link_myface" href="javascript:;">
						<span class="mui-pull-right mui-icon mui-icon-arrowright" style="line-height: 42px;color: lightgray;margin-left: 3px;"></span>
						<img id="img_my_face" class="mui-media-object mui-pull-right" src="image/face-default-cat.png">
						<div class="mui-media-body" style="line-height: 42px; font: 16px;">
							头像
						</div>
					</a>
				</li>
				<li class="mui-table-view-cell mui-media">
					<a id="link_nickName" href="javascript:;">
						<span class="mui-pull-right mui-icon mui-icon-arrowright" style="color: lightgray;margin-left: 3px;"></span>
						<span id="span_nick_name" class="mui-pull-right " style="color: gray;font: 14px;"></span>
						<div class="mui-media-body">
							昵称
						</div>
					</a>
				</li>
				<li class="mui-table-view-cell mui-media">
					<a  href="javascript:;">
						<span id="span_user_name" class="mui-pull-right " style="color: gray;font: 14px;"></span>
						<div class="mui-media-body">
							账号
						</div>
					</a>
				</li>
				<li class="mui-table-view-cell mui-media">
					<a id="link_my_qrcode" href="javascript:;">
						<span class="mui-pull-right mui-icon mui-icon-arrowright" style="color: lightgray;margin-left: 3px;"></span>
						<img class="mui-media-object mui-pull-right" style="max-width: 20px;max-height: 20px" src="image/qrcode.png">
						<div class="mui-media-body">
							我的二维码
						</div>
					</a>
				</li>
			</ul>

			<br/>
			<ul class="mui-table-view">
				<li class="mui-table-view-cell mui-media" style="text-align: center;">
					<a id="logout" href="javascript:;">
						<div class="mui-media-body">
							退出登录
						</div>
					</a>
				</li>
			</ul>
		</div>

		<script src="js/mui.min.js"></script>
		<script src="js/app.js"></script>
		<script type="text/javascript">
			mui.init()
			mui.plusReady(function() {
				//获取当前的webview，刷新当前的用户信息
				var meWebview = plus.webview.currentWebview();
				meWebview.addEventListener("show", function() {
					refreshUserInfo();
				});
				//添加自定义事件，刷新当前的用户信息
				window.addEventListener("refresh", function() {
					refreshUserInfo();
				});
				//页面跳转我的头像
				var link_myface = document.getElementById("link_myface");
				link_myface.addEventListener("tap",function(){
					mui.openWindow("myface.html","myface.html");
				});
				
				//跳转页面修改昵称
				var link_nickName = document.getElementById("link_nickName");
				link_nickName.addEventListener("tap",function(){
					mui.openWindow("mynickname.html","mynickname.html");
				});
				//页面跳转我的二维码
				var link_my_qrcode = document.getElementById("link_my_qrcode");
				link_my_qrcode.addEventListener("tap",function(){
					mui.openWindow({
						url:"myQRCode.html",
						id :"myQRCode.html",
						styles:{
							
						}
					});
				});
				
				//获取用户信息
				function refreshUserInfo() {
					var user = app.getUserGlobalInfo();
					if(user != null) {
						var faceImage = user.faceImage;
						var userName = user.userName;
						var nickName = user.nickName;

						var user_name = document.getElementById("span_user_name");
						var nick_name = document.getElementById("span_nick_name");
						user_name.innerHTML = userName;
						nick_name.innerHTML = nickName;
						if(app.isNotNull(faceImage)) {
							var img_my_face = document.getElementById("img_my_face");
							img_my_face.src = app.imgServerUrl + faceImage;
						}
					}
				};
				
				//退出登录页面跳转注册页面
				var logout = document.getElementById("logout");
				logout.addEventListener("tap",function(){
					app.setUserGlobalInfo(null);
					app.showToast("退出登录", "success");
					mui.openWindow("login.html","login.html");
				});
			})
		</script>
	</body>

</html>